<h2><span class="fn n"><%= @person.name %></span>'s Profile</h2>
<%- if current_person?(@person) || current_person.admin? -%>
  <div class="button_container">
<%- end -%>
<%- if current_person.admin? -%>
  <%- activity = activated_status(@person)  -%>
  <%= link_to activity,
              admin_person_path(@person, :task => "deactivated"),
              :method => :put %>
  <%= "|" if current_person?(@person) %>
<%- end -%>
<%- if current_person?(@person) -%>
  <%= link_to "Edit profile", edit_person_path(@person) %> |
  <%= link_to "Change photo", @person.galleries.first %>
<%- end -%>
<%- if current_person?(@person) || current_person.admin? -%>
    <div class="clear"></div>
  </div>
<%- end -%>
<%- if admin? and not @person.active? -%>
  <p class="error">This person is not active</p>
<%- end -%>
<%- if current_person?(@person) && current_person.description.blank? -%>
  <div class="error">
    Your description is blank.
    <%= link_to "Click here to add a description", 
      edit_person_path(@person) %>
  </div>
<%- end -%>

<div class="toolbox">
  <%= image_tag @person.main_photo, :class => "profile-image photo",
                                    :alt => h(@person.name) %>
  <%- unless current_person?(@person) -%>
    <h3><%= @person.name %></h3>
    <ul class="tools">
      <%- if logged_in? -%>
        <%- unless Connection.exists?(@person, current_person) -%>
          <li><%= link_to "Request Connection",
                          person_connections_path(@person),
                          :method => :post %></li>
        <%- end -%>
        <%- if Connection.connected?(@person, current_person) -%>
          <li>You're connected!
          <%= link_to image_tag('icons/user_delete.png'),
                      connection_path(Connection.conn(current_person,
                                                      @person)), 
                          :method => :delete,
                      :title => "Remove connection",
             :confirm => "Are you sure you want to remove this connection?" %>
          </li>
        <%- end -%>
          <%- if Connection.pending?(current_person, @person) -%>
          <li>
            <%= h @person.name %> has contacted you
            <br />
            (<%= link_to "respond to contact request", 
                         edit_connection_path(Connection.conn(current_person,
                                                              @person)) %>)
          </li>
          <%- end -%>
          <%- if Connection.pending?(@person, current_person) -%>
          <li>
            You've contacted <%= h @person.name %>
          </li>
          <%- end -%>
        <li><%= email_link(@person) %></li>
      <%- end -%>
    </ul>
  <%- end -%>
</div>
<%= display @person.description %>